package practica3;

import weka.core.*;
import weka.classifiers.meta.*;
import weka.classifiers.rules.OneR;

/**Clase que utiliza la libreria CVParameterSelection*/
public class CVParam {
	
	public CVParam(){}
	
	public void paramSelection(Instances data) throws Exception {
		CVParameterSelection ps = new CVParameterSelection();
		ps.setClassifier(new OneR());
		ps.setNumFolds(5); // 5-fold CV
		
		System.out.println("\n--------------------------------------------");
		System.out.println("UTILIZANDO LA LIBRERIA CVParameterSelection:");
		System.out.println("--------------------------------------------");
		try{
			ps.addCVParameter("B 1 "+data.numInstances()+" "+data.numInstances()); 
			ps.buildClassifier(data);
			System.out.println("Resultado: "+ Utils.joinOptions(ps.getBestClassifierOptions()));
		}catch(Exception e){
			System.out.println("Error: "+ e.getMessage());
		}
   }
}
